package com.example.bootdemo.injector;

import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import org.springframework.stereotype.Component;

/**
 * @author dyz
 * @program boot-use
 * @create 2019-09-11 16:09
 */
@Component
public class MySqlInjector extends DefaultSqlInjector {

/*    @Override
    public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
        List<AbstractMethod> methodList = super.getMethodList(mapperClass);
        //methodList.add(new DeleteAllMethod());
        methodList.add(new InsertBatchSomeColumn(t -> !t.isLogicDelete()));
        methodList.add(new LogicDeleteByIdWithFill());
        methodList.add(new AlwaysUpdateSomeColumnById(t -> !t.getColumn().equals("name")));
        return methodList;
    }*/

    /*@Override
    public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
        // 1. 获取父级创建的方法
        List<AbstractMethod> methodList = super.getMethodList(mapperClass);
        // 2. 增加组件，新增操作时，不会对逻辑删除字段进行设置
        *//** InsertBatchSomeColumn有无参和带参两种构造方法
     *	无参构造会将插入记录的所有属性进行设置
     *	带参构造可自定义具体对一条数据的哪些属性进行设置
     *//*
        methodList.add(new InsertBatchSomeColumn(new Predicate<TableFieldInfo>() {
            @Override
            public boolean test(TableFieldInfo tableFieldInfo) {
                return !tableFieldInfo.isLogicDelete();
                //return !tableFieldInfo.isLogicDelete() && !tableFieldInfo.getColumn().equals("name");
                // 排除多个字段的时候，用&&
            }
        }));
        // 3. 返回
        return methodList;
    }*/

}
